package com.edu.mapper;

import com.edu.bean.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StudentMapper {
    /*通过id查找指定学生*/
    @Select("SELECT * FROM student WHERE stuId=#{stuId}")
    Student selectStuById(int stuId);

    /*添加学生*/
    @Insert("INSERT INTO student(stuName,age,sex) value(#{stuName},#{age},#{sex})")
    int insertStu(Student student);

    /*通过id删除指定学生*/
    @Delete("DELETE FROM student WHERE stuId=#{stuId}")
    int deleteStuById(int stuId);

    /*通过id修改指定学生*/
    @Update("UPDATE student SET stuName=#{stuName},age=#{age},sex=#{sex} WHERE stuId=#{stuId}")
    int updateStuById(Student student);

    /*查找所有学生*/
    @Select("SELECT * FROM student")
    List<Student> selectAll();
}
